package Day2025_03_25;

import java.util.Arrays;

public class Demo02 {
    public int MLS (int[] arr) {
        // write code here
        int n = arr.length;
        Arrays.sort(arr);
        int ret = 1;
        int[] dp = new int[n];
        dp[0] = 1;
        for (int i = 1; i < n; i++) {
            if (arr[i] - arr[i - 1] == 1) dp[i] = dp[i - 1] + 1;
            ret = Math.max(ret, dp[i]);
        }
        return ret;
    }

    public static void main(String[] args) {
        Demo02 demo02 = new Demo02();
        System.out.println(demo02.MLS(new int[]{1, 1, 1, 1}));
    }
}
